import requests
import time
from bs4 import BeautifulSoup

url='https://www.ifeng.com/'
response=requests.get(url)
soup=BeautifulSoup(response.text,'html.parser')

news_list=soup.find_all('a',target='_blank')
news_cnt=0
for news in news_list:
    if not news.has_key('class') or not news.has_key('title') or not news.has_key('href'):
        continue
#    print(news)
    title=news['title']
    link=news['href']
    print("title:{0}".format(title))
    print("link:{0}".format(link))

    link_soup=BeautifulSoup(requests.get(link).text,'html.parser')
    print("content:")
    for content in link_soup.find_all('p'):
        text = content.text
        print(content.text)
    news_cnt+=1
    print("")

    time.sleep(10)

print(news_cnt)
